package com.sync.mutiParse;

import java.util.concurrent.atomic.AtomicInteger;

import com.constants.Constants;

/**
 * 针对64K的优化
 * 
 * @author LittleBearWinnie
 *
 */
public final class Block {
	public volatile int id = -1; // 第几个块
	public int limit = -1;// 块byte数组的长度,64k最多781
	public int[] curPKs = new int[8000];// 当前主键1024-128
	public int[] changePKs = new int[8000];// 变更主键
	public int[] pos = new int[8000];// 记录地址
	public byte[] types = new byte[8000];// 类型信息
	public byte[] buffer = new byte[Constants.BLOCK_SIZE_EXTEND];
	public int recordCount = -1;// 解析块，统计记录的数量
	public AtomicInteger readTimes = new AtomicInteger(0);// 这个块被重放线程读了多少次 ???
	// public ArrayBlockingQueue<Block> freeQueue;// 所属ringBuffer
	public Block() { }

	@Override
	public String toString() {
		return "id:" + id + " limit" + limit + " count:" + recordCount;
	}

	public void clear() {
		id = -1;
		limit = -1;
		recordCount = -1;
		readTimes.set(0);
	}
}
